package map.coreui.view

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.TextView
import com.baidu.mapapi.search.route.WalkingRouteLine
import com.zjw.zy.R
import com.zjw.zy.base.BaseViewGroup
import com.zjw.zy.utils.ResourcesUtils

/**
 * @author ：zhong.jw
 * @date ：Created in 2022/10/24 16:45
 */
class MultiRouteItemView : BaseViewGroup {

    private val state: TextView by lazy { findViewById(R.id.multi_route_item_view_state) }
    private val time: TextView by lazy { findViewById(R.id.multi_route_item_view_time) }
    private val distance: TextView by lazy { findViewById(R.id.multi_route_item_view_distance) }

    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    ) {
    }

    override fun onLayoutId(): Int {
        return R.layout.multi_route_item_view
    }

    override fun onBindListener() {

    }

    override fun onBindValue() {

    }

    override fun onFindView(rootView: View) {

    }

    fun bindData(line: WalkingRouteLine) {
        time.text =
            ResourcesUtils.getString(
                R.string.multi_route_item_view_time,
                line.duration.toFloat() / 60
            )
        distance.text =
            ResourcesUtils.getString(R.string.multi_route_item_view_distance, line.distance)
        state.text = ResourcesUtils.getString(
            R.string.multi_route_item_view_step,
            (line.distance.toDouble() / 0.47).toInt()
        )
    }
}